package com.picture;

import javax.swing.*;
import java.awt.*;

public class Tank extends JFrame {
    private MyPanel mp=null;
    public static void main(String[] args) {
        new Tank();

    }
    //初始化画板
    public Tank(){
        mp=new MyPanel();
        this.add(mp);
        this.setSize(680,480);//设置画板大小
        this.setVisible(true);//图像可视化
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//x结束程序
    }

}

class MyPanel extends JPanel{
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(Color.black);
        g.fillRect(0,0,680,480);
        g.setColor(Color.blue);//设置画笔颜色
        g.fill3DRect(100,100,20,60,true);//左边
        g.fill3DRect(140,100,20,60,true);//右边
        g.setColor(Color.red);
        g.fill3DRect(120,110,20,40,true);//中部
        g.setColor(Color.green);
        g.drawLine(130,80,130,130);

    }
}